package blue.qingyu.whimurmur.messageEx;

import java.util.Date;

import com.jfinal.aop.Inject;
import com.jfinal.core.ActionKey;
import com.jfinal.plugin.activerecord.Page;

import blue.qingyu.whimurmur.messageEx.model.WMPostClass;
import blue.qingyu.whimurmur.messageEx.service.WMPostClassService;
import io.jboot.db.model.Columns;
import io.jboot.web.controller.annotation.RequestMapping;
import io.jpress.JPressConsts;
import io.jpress.core.menu.annotation.AdminMenu;
import io.jpress.web.base.AdminControllerBase;


@RequestMapping(value = "/admin/addon/whimurmur/messageEx",viewPath = "/")
public class _MessageExAddonController extends AdminControllerBase {
	@Inject
	private WMPostClassService postClassService;
	
    @ActionKey("/admin/addon/whimurmur/messageEx/index")
    @AdminMenu(groupId = JPressConsts.SYSTEM_MENU_ADDON, text = "留言插件")
    public void index() {
    	Columns columns = new Columns();
    	columns.likeAppendPercent("post_class_name", getTrimPara("post_class_name"));
    	Page<WMPostClass> postClassPage = postClassService._paginate(getPagePara(), 10, columns);
//    	System.out.println(postClassPage.getList().size());
    	setAttr("postClassPage", postClassPage);
        render("messageExBack/index.html");
    }
    
    public void postClassEdit() {
    	Integer id = getParaToInt();
    	WMPostClass postClass = postClassService.findById(id);
    	setAttr("postClass", postClass);
    	render("messageExBack/postClassEdit.html");
    }
    
    public void postClassSave() {
    	WMPostClass postClass = getBean(WMPostClass.class);
    	if(postClass.getId() != null) {
    		postClassService.update(postClass);
    	}else {
    		postClass.setCreated(new Date());
    		postClassService.save(postClass);
    	}
    	
    	renderOkJson();
    }
    
    /* 显示 */
    public void queryCategorys() {
    	
    }
    
    public void queryCategoryMessages() {
    	
    }
    
    public void queryLatestMessages() {
    	
    }
    
    public void queryActiveMessages() {
    	
    }
    
    /* 留言 */
    public void queryMessage() {
    	
    }
    
    public void addMessage() {
    	
    }
    
    public void deleteMessage() {
    	
    }
    
    public void modifyMessage() {
    	
    }
    
    public void queryUnreadMessages() {
    	
    }
    
    public void readMessage() {
    	
    }
    
    public void readAll() {
    	
    }
    
    /* 分类 */
    public void addCategory() {
    	
    }
    
    public void modifyCategory() {
    	
    }
    
    public void deleteCategory() {
    	
    }
    

}
